package com.itgaoshu.hospitalproject.mapper;

import com.itgaoshu.hospitalproject.bean.Baoque;
import com.itgaoshu.hospitalproject.bean.Huishou;
import com.itgaoshu.hospitalproject.bean.Ypharmacy;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface PharmacyMapper{
    //查询药房药品
    List<Ypharmacy> selpharmacy(Ypharmacy ypharmacy);
    //添加药品到报缺表
    @Insert("INSERT into baoque(baoqueName,baoqueNum)VALUES(#{baoqueName},#{baoqueNum})")
    int addbaoque(Baoque baoque);
    //查询报缺表药品名称是否已存在
    @Select("SELECT count(*) from baoque where baoqueName=#{baoqueName}")
    int selbaoqueName(Baoque baoque);
    //修改数量
    @Update("UPDATE baoque set baoqueNum =(baoqueNum+#{baoqueNum}) where baoqueName=#{baoqueName}")
    int upbaoquenum(Baoque baoque);
    //回收给药房
    @Update("delete  from pharmacy where pharmacyId =#{pharmacyId}")
    int delpharymacy(Ypharmacy ypharmacy);
    //回收表
    @Update("insert into huishou(huishouname,huishounumber,huishoupihao,jbr,beizhu) VALUES(#{huishouname},#{huishounumber},#{huishoupihao},#{jbr},#{beizhu});\n")
    int addhuishou(Huishou huishou);
    //查询回收表
    @Select("select * from huishou")
    List<Huishou>selhuishou(Huishou huishou);
    //删除回收表
    @Update("delete  from huishou where huishouid=#{huishouid}")
    int delhuishou(Huishou huishou);
}